new Vue({
    el:"#app",
    data:{
        user:{
            id:"",
            name:"",
            money:""
        },
        userlist:[],
        iname:"",
        imoney:"",
        username:""
    },
    methods:{
        findAll:function(){
            var _this = this;
            axios.get('/user/findAll.do')
                .then(function (value) {
                    _this.userlist = value.data;
                }).catch(function (reason) {
                console.log(reason)
            })
        },
        addUser:function () {
            var _this = this;
            axios.get('/user/addUser.do',{params:{name:_this.iname,money:_this.imoney}}).then(function (value) {
                _this.findAll();
            })
        },
        deleteById:function (uid) {
            var _this = this;
            axios.get('/user/deleteById.do',{params:{id:uid}}).then(function (value) {
                _this.findAll();
            })
        },
        update:function(){
            var _this = this;
            axios.post('/user/updateUser.do',_this.user).then(function (value) {
                _this.findAll();
            })
        },
        findById:function (uid) {
            var _this = this;
            axios.get('/user/findById.do',{params:{id:uid}}).then(function (value) {
                _this.user = value.data;
                $("#myModal").modal("show");
            })
        },
        findByName:function () {
            var _this = this;
            axios.get('/user/findByName.do',{params:{name:_this.username}}).then(function (value) {
                _this.user =value.data
            })
        }
    },
    created() {
        this.findAll();
    }
});